import axios from "axios";
import querystring from "querystring";
function get(url, params) {
    return axios.get(url, { params })
}

function post(url, data, config = {}) {
    console.log(data);
    return axios.post(url, data, config);
}

axios.interceptors.request.use(function (request) {
    const method = request.method;
    console.log(request);
    if ("POST" === method.toLocaleUpperCase()) {
        request.data = querystring.stringify(request.data);
    }
  
    return request;
});

axios.interceptors.response.use(function(response){
    return response.data;
});
export { get, post };
